﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GenericLibrariesToolKit;
using Utils;
namespace Model
{
    /// <summary>
    /// 用户实体
    /// </summary>
    public class User
    {
        /*用户ID*/
        public string UserId { get; set; }
        /*用户密码*/
        public string UserPassword { get; set; }    
        /*用户类型*/
        public string UserType { get; set; }
        /*安全问题*/
        public string SecurityQuestion { get; set; }
        /*安全问题答案*/
        public string SecurityAnswer { get; set; }
        /*判断是否验证通过*/
        public int IsAuditing { get; set; }
        /*判断是否可见*/
        private int visible = 1;
        public int Visible
        {
            get { return visible; }
            set { visible = value; } 
        }
        /** 用户注册时间**/
        private string registerDate = DateTimeUtil.GetDateTime();
        public string RegisterDate
        {
            get { return registerDate; }
            set { registerDate = value; }
        }

        /// <summary>
        /// 应用程序启动时，实体管理器将会调用此方法进行初始化。
        /// </summary>
        public void Intialization()
        {
            //声明一个实体实体对象
            Entity entity = new Entity();

            //指定该实体对应数据库中的表名
            entity.TableName = "T_USER";
            //指定该实体的标识符
            entity.EntityId = "UserId";
            //指定主键生成策略
            entity.Generator = GenericLibrariesToolKit.Enumeration.PKGenerationStrategy.USER_INPUT;
            ///实体关系映射字典
            ///key:实体属性名称，value:对应的数据库中表的字段名
            Dictionary<string, string> dictionary = new Dictionary<string, string>();

            dictionary.Add("UserId", "USER_ID");
            dictionary.Add("UserPassword", "USER_PASSWORD");
            dictionary.Add("UserType", "USER_TYPE");
            dictionary.Add("SecurityQuestion", "SECURITY_QUESTION");
            dictionary.Add("SecurityAnswer", "SECURITY_ANSWER");
            dictionary.Add("IsAuditing", "ISAUDITING");
            dictionary.Add("Visible", "VISIBLE");
            dictionary.Add("RegisterDate", "Register_Date");

            //赋值
            entity.ORMDictionary = dictionary;

            //将实体加入实体管理器，
            EntityManager.GetInsatnce().AddEntity("Model.User", entity);
        }
    }
}
